package com.fs.user.web;

import com.fs.entity.User;
import com.fs.service.UserService;
import com.fs.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 1.编码处理
         * 2.获取请求参数
         * 3.调用业务层的方法
         * 4.响应结果(跳转资源)
         */


        int id = Integer.parseInt(request.getParameter("id"));

        UserService userService = new UserServiceImpl();
        userService.deleteById(id);

        //跳转到 ListServlet  重定向
        response.sendRedirect("/ListServlet");

    }
}
